package com.jt.tenant.wxapi;

import com.jt.tenant.R;
import com.jt.tenant.activity.GSPaymentActivity;
import com.jt.tenant.app.JTApplication;
import com.tencent.mm.sdk.modelbase.BaseReq;
import com.tencent.mm.sdk.modelbase.BaseResp;
import com.tencent.mm.sdk.openapi.IWXAPIEventHandler;
import com.zcx.helper.http.Http;
import com.zcx.helper.util.UtilToast;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler {

	@Override
	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_wx_pay_entry);

		JTApplication.lbjzwxPay.handleIntent(getIntent(), this);

	}

	@Override
	protected void onNewIntent(Intent intent) {

		super.onNewIntent(intent);

		setIntent(intent);

		JTApplication.lbjzwxPay.handleIntent(intent, this);

	}

	@Override
	public void onReq(BaseReq req) {

	}

	@Override
	public void onResp(BaseResp resp) {

		Http.getInstance().dismiss();

		switch (resp.errCode){

			case 0:

				new Handler(){

					@Override
					public void handleMessage(Message msg) {

//						OrderDetailsActivity.Change();
//
//						MyOrderActivity.Change();

					}

				}.sendEmptyMessageDelayed(0, 1000);


				if(GSPaymentActivity.wxSuccess != null){

					GSPaymentActivity.wxSuccess.success("1");

				}



				UtilToast.show(this, "支付成功");

				break;

			case -1:

				UtilToast.show(this, "支付失败");

				break;

			case -2:

				UtilToast.show(this, "支付取消");

				break;

		}

		finish();

	}

}
